﻿function wxconfig(data) {
    wx.config({
        beta: true,
        debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
        appId: data.appId, // 必填，公众号的唯一标识
        timestamp: data.timestamp, // 必填，生成签名的时间戳
        nonceStr: data.nonceStr, // 必填，生成签名的随机串
        signature: data.signature,//必填，签名，见附录1
        jsApiList: ['onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo',
        'onMenuShareQZone',
        'startRecord',
        'stopRecord',
        'onVoiceRecordEnd',
        'playVoice',
        'pauseVoice',
        'stopVoice',
        'onVoicePlayEnd',
        'uploadVoice',
        'downloadVoice',
        'chooseImage',
        'previewImage',
        'uploadImage',
        'downloadImage',
        'translateVoice',
        'getNetworkType',
        'openLocation',
        'getLocation',
        'hideOptionMenu',
        'showOptionMenu',
        'hideMenuItems',
        'showMenuItems',
        'hideAllNonBaseMenuItem',
        'showAllNonBaseMenuItem',
        'closeWindow',
        'scanQRCode',
        'chooseWXPay',
        'openProductSpecificView',
        'addCard',
        'chooseCard',
        'openCard'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
    });
}
wx.error(function () {
    alert("js签名验证失败");
});
import utils from './../../js/utils';

utils.ajax(utils.AJAX_SRC +'ddfwap/getWxconfig' , {rurl: location.href.split('#')[0]}).
then(result=>{
  wxconfig(result.wxdata);
});

//微信分享
wx.share = function (title, profile,url, faceImg) {
    wx.onMenuShareTimeline({
        title: title,
        link: url,
        imgUrl: faceImg,
        success: function () {
        }, cancel: function () {
        }
    })
    wx.onMenuShareAppMessage({
        title: title,
        desc: profile,
        link: url,
        imgUrl: faceImg,
        type: 'link',
        dataUrl: '',
        success: function () {
        },
        cancel: function () {
        }
    });
    wx.onMenuShareQQ({
        title: title,
        desc: profile,
        link: url,
        imgUrl: faceImg,
        success: function () {
        },
        cancel: function () {
        }
    });
    wx.onMenuShareQZone({
        title: title,
        desc: profile,
        link: url,
        imgUrl: faceImg,
        success: function () {
        },
        cancel: function () {
        }
    });

}
